<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <link rel="stylesheet" href="./css/header.css">
    <link rel="stylesheet" href="./css/nav.css">
    <link rel="stylesheet" href="./css/content.css">
    <link rel="stylesheet" href="./css/fixed.css">
    <meta name="author" content="李愧愧">
    <title></title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: '宋体';
        }

        ul {
            list-style: none;
        }

        li {
            float: left;
        }

        .top {
            width: 100%;
            height: 33px;
            border-bottom: 1px solid #ebebeb;
        }

        .top-content {
            float: right;
        }

        .top ul {
            display: inline-block;
            font-size: 0px;
        }

        .top ul li {
            margin-left: 22px;
            line-height: 33px;

        }

        .top ul li a {

            color: black;
            font-weight: 600;
            font-size: 13px;
            color: #222;
        }

        .top ul:nth-child(1) li:nth-child(10) {
            width: 0px;
            height: 20px;
            padding-right: 39px;
            border-right: 1px solid #e0e0e0;
            margin: 0px;
            margin-top: 6px;
        }

        .top ul:nth-child(1) li:nth-child(2) {
            font-size: 13px;
        }

        .top ul:nth-child(2) {
            margin-right: 20px;
        }

        .top ul:nth-child(2) li a {
            font-weight: normal;
            color: #222;
        }

        .red {
            background-color: #c00;
        }
    </style>
</head>

<body>
    <div class="top">
        <div class="top-content">
            <ul>
                <li><a href="">网页</a></li>
                <li>新闻</li>
                <li><a href="">贴吧</a></li>
                <li><a href="">知道</a></li>
                <li><a href="">音乐</a></li>
                <li><a href="">图片</a></li>
                <li><a href="">视频</a></li>
                <li><a href="">地图</a></li>
                <li><a href="">文库</a></li>
                <li></li>
            </ul>
            <ul>
                <li><a href="">百度首页</a></li>
                <li><a href="">登录</a></li>
                <li><a href="">注册</a></li>
                <li><a href="">百度新闻客户端</a></li>
            </ul>
        </div>
    </div>
    <div class="header">
        <div class="header-left"><img src="./img/baidulogo.png" alt=""></div>
        <div class="header-right">
            <span>
                <input type="text" placeholder="">
                <button>百度一下</button>
            </span>
            <a href="">帮助</a>
        </div>
    </div>
    <div class="nav-box">
        <div class="nav">
            <ul>
                <div class="bg"></div>
                <li class="red">
                    <i></i>
                    <a href="">首页</a>
                </li>
                <li><a href="">国内</a></li>
                <li><a href="">国际</a></li>
                <li><a href="">军事</a></li>
                <li><a href="">财经</a></li>
                <li><a href="">娱乐</a></li>
                <li><a href="">体育</a></li>
                <li><a href="">互联网</a></li>
                <li><a href="">科技</a></li>
                <li><a href="">游戏</a></li>
                <li><a href="">女人</a></li>
                <li><a href="">汽车</a></li>
                <li><a href="">房产</a></li>
            </ul>
        </div>
    </div>
    <div class="content">

    </div>
    <div class="fixeds">
        <ul>
            <li>
                <div class="fix-hove">
                    <a href="">举报</a>
                </div>
            </li>
            <li>
                <div class="fix-hove">
                    <a href="">二维码</a>
                </div>

            </li>
            <li>
                <div class="fix-hove">
                    <a href="">收藏本站</a>
                </div>
            </li>
            <li>
                <div class="fix-hove">
                    <a href="">搜索</a>
                </div>
            </li>
            <li>
                <div class="fix-hove">
                    <a href="">用户反馈</a>
                </div>
            </li>
            <li>
                <div class="fix-hove">

                </div>
            </li>
        </ul>
    </div>
    <script>
        var navlis = document.querySelectorAll('.nav ul li');
        console.dir(navlis);
        // 固定位置
        var nav = document.querySelector('.nav-box');
        var fix = document.querySelector('.fixeds');
        var ul = document.querySelector('.nav ul');
        var bg = document.querySelector('.nav ul .bg');

        console.dir(nav);

        // 固定框
        window.onscroll = function (ev) {
            var scrollTop = document.scrollingElement.scrollTop;
            if (scrollTop >= 86) {
                nav.style.position = 'fixed';
                fix.style = 'animation: move 0.5s linear; bottom: 10px;'
            } else {
                nav.style.position = 'static';
                fix.style = 'animation: moveover 0.5s linear; bottom: -51px;'
            }
        }
        // 导航栏
        for (var i = 0; i < navlis.length; i++) {
            var offsetLeft = navlis[i].offsetLeft;
            console.dir(offsetLeft);
            navlis[i].onmouseenter = function (ev) {
                bg.style.left = this.offsetLeft + 'px';
                bg.style.width = this.offsetWidth + 'px';
                console.dir(this.offsetLeft,this.offsetWidth );
            }
            navlis[i].onmouseleave = function(ev){
                bg.style.cssText = '';
            }
        }
    </script>
</body>

</html>